<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us" data-whc_version="24.1">
    <head><link rel="shortcut icon" href="oxygen-webhelp\template\resources/images/favicon.ico"/><link rel="icon" href="oxygen-webhelp\template\resources/images/favicon.ico"/><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="copyright" content="(C) Copyright 2024"/><meta name="generator" content="DITA-OT"/><meta name="description" content="Follow the following steps to utilize Model-Based Design in Harmony QSpin. Note: Presently, this support is available only for PIC32MK, SAME70, SAME54, and SAMRH707 device families. 1. Install X2C ..."/>        
      <title>2.2.1.2.1 Steps to Utilize Model-Based Design in Harmony QSpin</title><!--  Generated with Oxygen version 24.1, build number 2022062014.  --><meta name="wh-path2root" content=""/><meta name="wh-toc-id" content="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859-d1956e134"/><meta name="wh-source-relpath" content="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859.xml"/><meta name="wh-out-relpath" content="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859.html"/>
    <!-- Latest compiled and minified Bootstrap CSS -->
    <link rel="stylesheet" type="text/css" href="./oxygen-webhelp/lib/bootstrap/css/bootstrap.min.css"/>
    
    <link rel="stylesheet" href="./oxygen-webhelp/lib/jquery-ui/jquery-ui.min.css"/>
    
    <!-- Template default styles  -->
    <link rel="stylesheet" type="text/css" href="./oxygen-webhelp/app/topic-page.css?buildId=2022062014"/>
    
    
    <script src="./oxygen-webhelp/lib/jquery/jquery-3.5.1.min.js"></script>
    
    <script data-main="./oxygen-webhelp/app/topic-page.js" src="./oxygen-webhelp/lib/requirejs/require.js"></script>
<link rel="stylesheet" type="text/css" href="oxygen-webhelp/template/microchip.css?buildId=2022062014"/><link rel="stylesheet" type="text/css" href="oxygen-webhelp/template/notes.css?buildId=2022062014"/>
<script src="mchp-context-help.js"></script>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,300" rel="stylesheet" type="text/css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async="" type="text/javascript"></script>
    <script src="https://assets.adobedtm.com/6a72a357eb48/a636c708c7fe/launch-0b0023397020.min.js"></script><!-- Adobe Analytics -->
</head>

    <body id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859" class="wh_topic_page frmBody">
        <a href="#wh_topic_body" class="sr-only sr-only-focusable">
            Jump to main content
        </a>
        
        
        
        
        <header class="navbar navbar-default wh_header">
    <div class="container-fluid">
        <div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
            <div class="wh_logo_and_publication_title_container">
                <div class="wh_logo_and_publication_title">
                    
                    <a href="index.html" class=" wh_logo d-none d-sm-block "><img src="oxygen-webhelp\template\resources/images/microchip.png" alt="MPLAB® Harmony 3 Motor Control &#xA;    "/></a>
                    <div class=" wh_publication_title "><a href="index.html">MPLAB® Harmony 3 Motor Control 
    </a></div>
                    
                </div>
                
                
            </div>

            <div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
                
                
                
                
            </div>
        </div>
    </div>
</header>
        
        
         
        
        <div class=" wh_search_input navbar-form wh_topic_page_search search " role="form">
            
            
            
            <form id="searchForm" method="get" role="search" action="search.html"><div class="d-flex justify-contents-around"><div class="flex-grow-1"></div><div class="position-relative flex-grow-1"><input type="search" placeholder="Search " class="wh_search_textfield" id="textToSearch" name="searchQuery" aria-label="Search query" required="required"/><button type="submit" class="wh_search_button" aria-label="Search"><span class="search_input_text">Search</span></button></div><div class="align-self-center flex-grow-1 ml-2"></div></div></form>
            
            <div class="mchp-color-stripe-grid-container">
  <div class="mchp-main-bar mchp-orange-bar"></div>
  <div class="mchp-main-bar mchp-blue-bar"></div>
  <div class="mchp-main-bar mchp-green-bar"></div>
</div>
            
        </div>
        
        <div class="container-fluid" id="wh_topic_container">
            <div class="row">

                <nav class="wh_tools d-print-none navbar-expand-md" aria-label="Tools">
                    
                    <div data-tooltip-position="bottom" class=" wh_breadcrumb "><ol class="d-print-none"><li><span class="home"><a href="index.html"><span>Home</span></a></span></li><li><div class="topicref" data-id="GUID-60DDB34A-7CBA-4DE1-814C-88D432196E35"><div class="title"><a href="GUID-60DDB34A-7CBA-4DE1-814C-88D432196E35.html"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2</ph>
Harmony QSpin - PMSM FOC</a></div></div></li><li><div class="topicref" data-id="GUID-35451F85-BBB3-4DF6-B3AC-00FB57657EFF"><div class="title"><a href="GUID-35451F85-BBB3-4DF6-B3AC-00FB57657EFF.html"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2</ph>
Harmony QSpin: PMSM FOC Modules</a></div></div></li><li><div class="topicref" data-id="GUID-E5EED18A-CF3E-4DA4-B210-950FDB8FA076"><div class="title"><a href="GUID-E5EED18A-CF3E-4DA4-B210-950FDB8FA076.html"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1</ph>
Software Modules</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li><li><div class="topicref" data-id="GUID-1247DA32-16EE-410F-8821-9996138029EC"><div class="title"><a href="GUID-1247DA32-16EE-410F-8821-9996138029EC.html"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.2</ph>
Motor Control and Diagnosis</a></div></div></li><li class="active"><div class="topicref" data-id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859"><div class="title"><a href="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859.html"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.2.1</ph>
Steps to Utilize Model-Based Design in Harmony QSpin</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li></ol></div>
                    
                    
                    
                    <div class="wh_right_tools">
                        <button class="wh_hide_highlight" aria-label="Toggle search highlights" title="Toggle search highlights"></button>
                        <button class="webhelp_expand_collapse_sections" data-next-state="collapsed" aria-label="Collapse sections" title="Collapse sections"></button>
                        
                        
                        
                        
                        <div class=" wh_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="Print this page" aria-label="Print this page"></button></div>
                        
                        <button type="button" id="wh_toc_button" class="custom-toggler navbar-toggler collapsed wh_toggle_button navbar-light" aria-expanded="false" aria-label="Toggle publishing table of content" aria-controls="wh_publication_toc">
                            <span class="navbar-toggler-icon"></span>
                        </button>
                    </div>
                    
                </nav>
            </div>
            
            <div class="row" style="margin-top: -1em;"><div class="col-lg-7 col-md-7 col-sm-12 offset-lg-3 offset-md-3 text-right border-bottom mb-1"><h2 class="text-dark header_title">
    </h2></div></div>
            
            
            <div class="wh_content_area">
                <div class="row">
                    
                        <nav id="wh_publication_toc" class="col-lg-3 col-md-3 col-sm-12 d-md-block d-none d-print-none" aria-label="Table of Contents Container">
                            <div id="wh_publication_toc_content">
		                        
                            	<div class=" wh_publication_toc " data-tooltip-position="right"><span class="expand-button-action-labels"><span id="button-expand-action" role="button" aria-label="Expand"></span><span id="button-collapse-action" role="button" aria-label="Collapse"></span><span id="button-pending-action" role="button" aria-label="Pending"></span></span><ul role="tree" aria-label="Table of Contents"><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-7BBD04D6-F959-4DB3-986C-62130FAEF07C-d1956e11" class="topicref" data-id="GUID-7BBD04D6-F959-4DB3-986C-62130FAEF07C" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-7BBD04D6-F959-4DB3-986C-62130FAEF07C-d1956e11-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-7BBD04D6-F959-4DB3-986C-62130FAEF07C.html" id="GUID-7BBD04D6-F959-4DB3-986C-62130FAEF07C-d1956e11-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">1</ph>
Introduction</a></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="GUID-60DDB34A-7CBA-4DE1-814C-88D432196E35-d1956e52" class="topicref" data-id="GUID-60DDB34A-7CBA-4DE1-814C-88D432196E35" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action GUID-60DDB34A-7CBA-4DE1-814C-88D432196E35-d1956e52-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-60DDB34A-7CBA-4DE1-814C-88D432196E35.html" id="GUID-60DDB34A-7CBA-4DE1-814C-88D432196E35-d1956e52-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2</ph>
Harmony QSpin - PMSM FOC</a></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-0E28D069-94DC-4B85-967B-CBF9A45BE525-d1956e60" class="topicref" data-id="GUID-0E28D069-94DC-4B85-967B-CBF9A45BE525" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-0E28D069-94DC-4B85-967B-CBF9A45BE525-d1956e60-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-0E28D069-94DC-4B85-967B-CBF9A45BE525.html" id="GUID-0E28D069-94DC-4B85-967B-CBF9A45BE525-d1956e60-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.1</ph>
Getting Started</a></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="GUID-35451F85-BBB3-4DF6-B3AC-00FB57657EFF-d1956e98" class="topicref" data-id="GUID-35451F85-BBB3-4DF6-B3AC-00FB57657EFF" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action GUID-35451F85-BBB3-4DF6-B3AC-00FB57657EFF-d1956e98-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-35451F85-BBB3-4DF6-B3AC-00FB57657EFF.html" id="GUID-35451F85-BBB3-4DF6-B3AC-00FB57657EFF-d1956e98-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2</ph>
Harmony QSpin: PMSM FOC Modules</a></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem" aria-expanded="true"><div data-tocid="GUID-E5EED18A-CF3E-4DA4-B210-950FDB8FA076-d1956e106" class="topicref" data-id="GUID-E5EED18A-CF3E-4DA4-B210-950FDB8FA076" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action GUID-E5EED18A-CF3E-4DA4-B210-950FDB8FA076-d1956e106-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-E5EED18A-CF3E-4DA4-B210-950FDB8FA076.html" id="GUID-E5EED18A-CF3E-4DA4-B210-950FDB8FA076-d1956e106-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1</ph>
Software Modules</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem"><div data-tocid="GUID-2E524004-ED37-4174-9ECC-3075003F70A7-d1956e116" class="topicref" data-id="GUID-2E524004-ED37-4174-9ECC-3075003F70A7" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-2E524004-ED37-4174-9ECC-3075003F70A7.html" id="GUID-2E524004-ED37-4174-9ECC-3075003F70A7-d1956e116-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.1</ph>
Start-up Configurator</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="GUID-1247DA32-16EE-410F-8821-9996138029EC-d1956e126" class="topicref" data-id="GUID-1247DA32-16EE-410F-8821-9996138029EC" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action GUID-1247DA32-16EE-410F-8821-9996138029EC-d1956e126-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-1247DA32-16EE-410F-8821-9996138029EC.html" id="GUID-1247DA32-16EE-410F-8821-9996138029EC-d1956e126-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.2</ph>
Motor Control and Diagnosis</a></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem" aria-expanded="true" class="active"><div data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859-d1956e134" class="topicref" data-id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action GUID-8E33A93C-1843-48AF-81A9-56CF2B306859-d1956e134-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859.html" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859-d1956e134-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.2.1</ph>
Steps to Utilize Model-Based Design in Harmony QSpin</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem"><div data-tocid="GUID-B29F400A-E501-4598-BF31-BE7C7EC28F31-d1956e144" class="topicref" data-id="GUID-B29F400A-E501-4598-BF31-BE7C7EC28F31" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-B29F400A-E501-4598-BF31-BE7C7EC28F31.html" id="GUID-B29F400A-E501-4598-BF31-BE7C7EC28F31-d1956e144-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.2.1.1</ph>
Installing X2C Library</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li></ul></li></ul></li><li role="treeitem"><div data-tocid="GUID-52CA4CA5-55BC-423F-B79E-B814E889984B-d1956e154" class="topicref" data-id="GUID-52CA4CA5-55BC-423F-B79E-B814E889984B" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-52CA4CA5-55BC-423F-B79E-B814E889984B.html" id="GUID-52CA4CA5-55BC-423F-B79E-B814E889984B-d1956e154-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.3</ph>
Output Stage</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li><li role="treeitem"><div data-tocid="GUID-D30380EE-7150-40F0-8CD4-972379CEF307-d1956e164" class="topicref" data-id="GUID-D30380EE-7150-40F0-8CD4-972379CEF307" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-D30380EE-7150-40F0-8CD4-972379CEF307.html" id="GUID-D30380EE-7150-40F0-8CD4-972379CEF307-d1956e164-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.4</ph>
Current Measurement and Diagnosis</a></div></div></li><li role="treeitem"><div data-tocid="GUID-01B46490-213A-4272-8195-738256105928-d1956e172" class="topicref" data-id="GUID-01B46490-213A-4272-8195-738256105928" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-01B46490-213A-4272-8195-738256105928.html" id="GUID-01B46490-213A-4272-8195-738256105928-d1956e172-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.5</ph>
Voltage Measurement and Diagnosis</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li><li role="treeitem"><div data-tocid="GUID-3FC371D1-5F20-4FD5-BE9C-5E735208822F-d1956e182" class="topicref" data-id="GUID-3FC371D1-5F20-4FD5-BE9C-5E735208822F" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-3FC371D1-5F20-4FD5-BE9C-5E735208822F.html" id="GUID-3FC371D1-5F20-4FD5-BE9C-5E735208822F-d1956e182-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.6</ph>
Position Measurement and Diagnosis</a></div></div></li><li role="treeitem"><div data-tocid="GUID-04C38070-686B-47B2-92B4-277FB5A980FC-d1956e190" class="topicref" data-id="GUID-04C38070-686B-47B2-92B4-277FB5A980FC" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-04C38070-686B-47B2-92B4-277FB5A980FC.html" id="GUID-04C38070-686B-47B2-92B4-277FB5A980FC-d1956e190-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.1.7</ph>
Data Monitoring</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li></ul></li><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-ECF85ABD-803D-4969-8737-C0CA3DBC62EA-d1956e200" class="topicref" data-id="GUID-ECF85ABD-803D-4969-8737-C0CA3DBC62EA" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-ECF85ABD-803D-4969-8737-C0CA3DBC62EA-d1956e200-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-ECF85ABD-803D-4969-8737-C0CA3DBC62EA.html" id="GUID-ECF85ABD-803D-4969-8737-C0CA3DBC62EA-d1956e200-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.2</ph>
Hardware Modules</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-5CB16768-D98D-45EA-805F-343C7E896621-d1956e238" class="topicref" data-id="GUID-5CB16768-D98D-45EA-805F-343C7E896621" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-5CB16768-D98D-45EA-805F-343C7E896621-d1956e238-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-5CB16768-D98D-45EA-805F-343C7E896621.html" id="GUID-5CB16768-D98D-45EA-805F-343C7E896621-d1956e238-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.2.3</ph>
Peripheral Modules</a></div></div></li></ul></li><li role="treeitem"><div data-tocid="GUID-F8D4D059-6217-4066-BD8B-60DD5B0B9DF3-d1956e270" class="topicref" data-id="GUID-F8D4D059-6217-4066-BD8B-60DD5B0B9DF3" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-F8D4D059-6217-4066-BD8B-60DD5B0B9DF3.html" id="GUID-F8D4D059-6217-4066-BD8B-60DD5B0B9DF3-d1956e270-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">2.3</ph>
Firmware Architecture</a></div></div></li></ul></li><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-5D9A13C4-45FC-4744-B788-8853716E4AD8-d1956e279" class="topicref" data-id="GUID-5D9A13C4-45FC-4744-B788-8853716E4AD8" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-5D9A13C4-45FC-4744-B788-8853716E4AD8-d1956e279-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-5D9A13C4-45FC-4744-B788-8853716E4AD8.html" id="GUID-5D9A13C4-45FC-4744-B788-8853716E4AD8-d1956e279-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">3</ph>
Harmony QSpin API Reference</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-42876005-92C2-4CC0-81FC-71368462D294-d1956e2164" class="topicref" data-id="GUID-42876005-92C2-4CC0-81FC-71368462D294" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-42876005-92C2-4CC0-81FC-71368462D294-d1956e2164-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-42876005-92C2-4CC0-81FC-71368462D294.html" id="GUID-42876005-92C2-4CC0-81FC-71368462D294-d1956e2164-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">4</ph>
Motor Control Development Kits and Boards</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-CB69EAC9-E44C-42F1-8521-F40F4CE2BC62-d1956e2180" class="topicref" data-id="GUID-CB69EAC9-E44C-42F1-8521-F40F4CE2BC62" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-CB69EAC9-E44C-42F1-8521-F40F4CE2BC62-d1956e2180-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-CB69EAC9-E44C-42F1-8521-F40F4CE2BC62.html" id="GUID-CB69EAC9-E44C-42F1-8521-F40F4CE2BC62-d1956e2180-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">5</ph>
Motor Control Example Projects</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li><li role="treeitem"><div data-tocid="GUID-05FBE3B7-EA31-4FD0-BA88-715B91E2D508-d1956e2241" class="topicref" data-id="GUID-05FBE3B7-EA31-4FD0-BA88-715B91E2D508" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-05FBE3B7-EA31-4FD0-BA88-715B91E2D508.html" id="GUID-05FBE3B7-EA31-4FD0-BA88-715B91E2D508-d1956e2241-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">6</ph>
Microchip MPLAB® Harmony 3 Release Notes</a></div></div></li><li role="treeitem"><div data-tocid="GUID-5AE41BEF-D04E-41F6-AA77-5469CF13B183-d1956e2250" class="topicref" data-id="GUID-5AE41BEF-D04E-41F6-AA77-5469CF13B183" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="GUID-5AE41BEF-D04E-41F6-AA77-5469CF13B183.html" id="GUID-5AE41BEF-D04E-41F6-AA77-5469CF13B183-d1956e2250-link"><ph xmlns="http://www.oxygenxml.com/ns/webhelp/toc">7</ph>
License</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="GUID-0FB3F908-88EE-45CE-94F5-E97AF9049C9B-d1956e2259" class="topicref backmatter backmatter_parent" data-id="GUID-0FB3F908-88EE-45CE-94F5-E97AF9049C9B" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action GUID-0FB3F908-88EE-45CE-94F5-E97AF9049C9B-d1956e2259-link" class="wh-expand-btn"></span><div class="title"><a href="GUID-0FB3F908-88EE-45CE-94F5-E97AF9049C9B.html" id="GUID-0FB3F908-88EE-45CE-94F5-E97AF9049C9B-d1956e2259-link">Microchip Information</a></div></div></li></ul></div>
		                        
                            </div>
                        </nav>
                    
                    
                    <div class="col-lg-7 col-md-9 col-sm-12" id="wh_topic_body">
                        <button id="wh_close_publication_toc_button" class="close-toc-button d-none" aria-label="Toggle publishing table of content" aria-controls="wh_publication_toc" aria-expanded="true">
                            <span class="close-toc-icon-container">
                                <span class="close-toc-icon"></span>     
                            </span>
                        </button>
                        <button id="wh_close_topic_toc_button" class="close-toc-button d-none" aria-label="Toggle topic table of content" aria-controls="wh_topic_toc" aria-expanded="true">
                            <span class="close-toc-icon-container">
                                <span class="close-toc-icon"></span>     
                            </span>
                        </button>
                        
                        <div class=" wh_topic_content body "><main role="main"><article role="article" aria-labelledby="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-6E32D56D-697E-46F3-A64D-05670B1480DC">
    <h1 class="- topic/title title topictitle1" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-6E32D56D-697E-46F3-A64D-05670B1480DC" style="">2.2.1.2.1 Steps to Utilize Model-Based Design in Harmony QSpin</h1>
    
    <div class="- topic/body body"><p class="- topic/shortdesc shortdesc"></p>
        <p class="- topic/p p">Follow the following steps to utilize Model-Based Design in Harmony QSpin.</p>
        <div class="- topic/note note notype note_notype" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-A879366C-A093-4B41-9537-B1E03A1D0501" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-A879366C-A093-4B41-9537-B1E03A1D0501"><span class="note__title">Note:</span> 
            <p class="- topic/p p">Presently, this support is available only for PIC32MK, SAME70, SAME54, and SAMRH707 device families.</p>
        </div>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-95205A12-24F9-4E17-85FB-6F9374F13B23" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-95205A12-24F9-4E17-85FB-6F9374F13B23"><h2 class="- topic/title title sectiontitle">1. Install X2C Library</h2>
            
            <p class="- topic/p p">Refer to the <a class="- topic/xref xref" href="GUID-B29F400A-E501-4598-BF31-BE7C7EC28F31.html">installation instructions</a> to install the X2C library (if not already installed).</p>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-0C3637C8-4598-4C4C-AE27-E40E416EC54C" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-0C3637C8-4598-4C4C-AE27-E40E416EC54C"><h2 class="- topic/title title sectiontitle">2. Configure Harmony QSpin GUI</h2>
            
            <p class="- topic/p p">Create MCC Harmony Project and configure the motor, peripherals, and hardware as mentioned in the <a class="- topic/xref xref" href="GUID-0E28D069-94DC-4B85-967B-CBF9A45BE525.html">Getting Started</a> section.</p>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-057F0C76-F1F4-41C8-BA20-9516CDCFD6DF" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-057F0C76-F1F4-41C8-BA20-9516CDCFD6DF"><h2 class="- topic/title title sectiontitle">3. Navigate to the Motor Control and Diagnosis Block</h2>
            
            <p class="- topic/p p">Open Harmony QSpin GUI and navigate to the Motor Control and Diagnosis block.</p>
            <div class=""><img class="- topic/image image break break" src="GUID-5A538CAD-D714-4155-B969-9FD301B9C2CA-high.jpg" alt="Open 'Motor Control Diagnosis' block"/></div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-81A78B90-F177-4D2F-ABFE-BA985CEE166A" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-81A78B90-F177-4D2F-ABFE-BA985CEE166A"><h2 class="- topic/title title sectiontitle">4. Enable Model-Based Development Option</h2>
            
            <p class="- topic/p p">Within the Motor Control and Diagnosis block, check the "Model Based Development" option. This setting instructs QSpin to generate wrapper files instead of code for motor control.</p>
            <div class=""><img class="- topic/image image break break" src="GUID-1C656930-F595-46C5-8C7B-12139693D22B-high.jpg" alt="Enable model-based design checkbox"/></div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C03271F4-F804-44EC-B512-C05981E5A3B9" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C03271F4-F804-44EC-B512-C05981E5A3B9"><h2 class="- topic/title title sectiontitle">5. Generate C Code from MCC</h2>
            
            <p class="- topic/p p">Use the Motor Control Center (MCC) to generate the C code necessary for your project.</p>
            <div class=""><img class="- topic/image image break break" src="GUID-F693D674-7926-4885-AE09-54AEEEE029D6-high.jpg" alt="Generate MCC Harmony code"/></div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-E130B9D4-8519-4A69-A468-707888102AA4" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-E130B9D4-8519-4A69-A468-707888102AA4"><h2 class="- topic/title title sectiontitle">6. Launch Scilab for X2C-based Model-Based Design</h2>
            
            <p class="- topic/p p">There are two ways to launch Scilab for X2C-based model-based design:</p>
            <div class="- topic/sectiondiv sectiondiv">
                <p class="- topic/p p"><strong class="+ topic/ph hi-d/b ph b">Using a Batch File:</strong></p>
                <ol class="- topic/ol ol" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-E5D5BCD6-F325-4C76-AF73-B7F1103989CD" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-E5D5BCD6-F325-4C76-AF73-B7F1103989CD">
                    <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-89DD50FE-60CA-41E3-826A-431399BD113C" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-89DD50FE-60CA-41E3-826A-431399BD113C">Navigate to the project explorer and locate the following path: <code class="+ topic/ph pr-d/codeph ph codeph">Important Files -&gt; config -&gt; default -&gt; X2CCode</code>.</li>
                    <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-62B267ED-090D-4CD5-97E6-19608694CB55" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-62B267ED-090D-4CD5-97E6-19608694CB55">Find the file named <code class="+ topic/ph pr-d/codeph ph codeph">launch_x2c_scilab.bat</code>.</li>
                    <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-F0C3014B-7F87-4D67-8ECB-431487DE5864" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-F0C3014B-7F87-4D67-8ECB-431487DE5864">Right-click on <code class="+ topic/ph pr-d/codeph ph codeph">launch_x2c_scilab.bat</code> and select "Run" to launch Scilab automatically.</li>
                </ol>
                <p class="- topic/p p"><div class=""><img class="- topic/image image" src="GUID-FF68BCD8-EFAD-4A40-86EE-ED343BB0FB04-high.jpg" alt="Launch Scilab from batch file"/></div></p>
            </div>
            <div class="- topic/sectiondiv sectiondiv">
                <p class="- topic/p p"><strong class="+ topic/ph hi-d/b ph b">Manual Steps:</strong></p>
                <ol class="- topic/ol ol" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-00239E32-D27E-4EC5-92C7-8BA253655333" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-00239E32-D27E-4EC5-92C7-8BA253655333">
                    <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-A101369F-7BD1-42B9-8A81-E7A9ED0A21C4" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-A101369F-7BD1-42B9-8A81-E7A9ED0A21C4">Open Windows Explorer and manually launch Scilab.</li>
                    <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-0D1D497C-1C17-478D-97E8-C21ECF2C2CFD" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-0D1D497C-1C17-478D-97E8-C21ECF2C2CFD">Navigate to the X2C code directory within your project, ensuring that <code class="+ topic/ph pr-d/codeph ph codeph">X2CCode</code> is set as the root folder.</li>
                    <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-CBCDE3DE-AAB0-4B65-BD4F-8A5139591AF8" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-CBCDE3DE-AAB0-4B65-BD4F-8A5139591AF8">In this directory, locate the <code class="+ topic/ph pr-d/codeph ph codeph">initProject.sce</code> file and execute it to initialize the project in Scilab.</li>
                </ol>
                <div class="- topic/p p"><div class=""><img class="- topic/image image break break" src="GUID-9D71F266-17C3-40E0-A0E5-CAECB08D2C4E-high.jpg" alt="Launch Scilab from Windows Explorer"/></div></div>
                <p class="- topic/p p"><div class=""><img class="- topic/image image" src="GUID-EA183420-D513-411B-86C6-6F7465936CE2-high.jpg" alt="Launch Model from Scilab"/></div></p>
            </div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1B9CBDA1-5360-4FD5-980F-54598F67FBDA" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1B9CBDA1-5360-4FD5-980F-54598F67FBDA"><h2 class="- topic/title title sectiontitle">7. Model Creation in X2C</h2>
            
            <p class="- topic/p p">Use X2C to create your model. For detailed instructions and guidance on model creation, transformation, and other relevant processes, refer to the following resources:</p>
            <ul class="- topic/ul ul">
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-7A19B0CB-ADD3-4EE7-9E88-DDF7C7015D7C" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-7A19B0CB-ADD3-4EE7-9E88-DDF7C7015D7C"><a class="- topic/xref xref" href="HTTPS://X2C.LCM.AT/" target="_blank" rel="external noopener">X2C - Model based development and Code
                        generation</a></li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-D848B8D7-250B-4DBA-A86E-8E9673B5CCDA" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-D848B8D7-250B-4DBA-A86E-8E9673B5CCDA"><a class="- topic/xref xref" href="HTTPS://WWW.MICROCHIP.COM/EN-US/SOLUTIONS/TECHNOLOGIES/MOTOR-CONTROL-AND-DRIVE/MOTOR-CONTROL-SIMULATIONS/SCILAB-AND-X2C" target="_blank" rel="external noopener">Scilab® and X2C Open-Source Tools for Motor Control Development</a></li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-702CA575-E775-4BBD-B393-5E8BF4BDDA99" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-702CA575-E775-4BBD-B393-5E8BF4BDDA99"><a class="- topic/xref xref" href="HTTPS://GITHUB.COM/MICROCHIP-MPLAB-HARMONY/X2C/TREE/MASTER/X2C-MODEL#README" target="_blank" rel="external noopener">Harmony X2C Model</a></li>
            </ul>
            <div class="- topic/note note notype note_notype" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1EDE1A19-3544-4C3B-B981-CD32AA7AD3EB" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1EDE1A19-3544-4C3B-B981-CD32AA7AD3EB"><span class="note__title">Note:</span> 
                <p class="- topic/p p">You can use sample X2C models from <code class="+ topic/ph pr-d/codeph ph codeph">motor_control-&gt;algorithms-&gt;pmsm_foc-&gt;config-&gt;x2c-models</code> to start your model based design.</p>
            </div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-F2074090-283A-43A4-9BC4-EE2336D843FB" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-F2074090-283A-43A4-9BC4-EE2336D843FB"><h2 class="- topic/title title sectiontitle">8. Transform and Generate Code</h2>
            
            <ol class="- topic/ol ol" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-7C3E54C4-FDE2-4968-A108-C44DA290CDB6" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-7C3E54C4-FDE2-4968-A108-C44DA290CDB6">
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-4A86EF01-8D1F-408D-BEB7-E212E0CBF6A2" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-4A86EF01-8D1F-408D-BEB7-E212E0CBF6A2">Click on "transform model and push to communicator".</li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-A0CF97B7-40E6-44B2-B96D-C839408BAD78" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-A0CF97B7-40E6-44B2-B96D-C839408BAD78">Click on "Start Communicator".</li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-03CE84CE-CA7B-4DF1-BC01-A2E33E6E0EE2" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-03CE84CE-CA7B-4DF1-BC01-A2E33E6E0EE2">Wait till you see "Model Set" in the log.</li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-CDD6B84B-BA21-482F-B3E6-AD70492A9D76" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-CDD6B84B-BA21-482F-B3E6-AD70492A9D76">Click on "Create Code" button.</li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1973B77C-EAE1-4909-91D1-397546002588" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1973B77C-EAE1-4909-91D1-397546002588">Transform your model in X2C and generate code as per your project requirements.</li>
            </ol>
            
            <div class="- topic/note note notype note_notype" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-4F184AA2-7494-4F82-B1EA-5FB91ED3DF41" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-4F184AA2-7494-4F82-B1EA-5FB91ED3DF41"><span class="note__title">Note:</span> 
                <p class="- topic/p p">Your model name and files may differ from those shown in the figure, depending on your configuration, model, and version.</p>
            </div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-30B40A7B-8755-4878-B8EE-C28378EB60E1" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-30B40A7B-8755-4878-B8EE-C28378EB60E1"><h2 class="- topic/title title sectiontitle">9. Update "readInports" and "writeOutports" Function Calls in MPLABX Project</h2>
            
            <p class="- topic/p p">Open <code class="+ topic/ph pr-d/codeph ph codeph">mc_field_oriented_control.h</code> from <code class="+ topic/ph pr-d/codeph ph codeph">source-&gt;config-&gt;default-&gt;QSpin-&gt;Field_Oriented_Control</code>.</p>
            <p class="- topic/p p">Update <code class="+ topic/ph pr-d/codeph ph codeph">readInports()</code> and <code class="+ topic/ph pr-d/codeph ph codeph">writeOutports()</code> as shown in the provided code snippet.</p>
            <div class="- topic/sectiondiv sectiondiv">
                <p class="- topic/p p"><strong class="+ topic/ph hi-d/b ph b">Input Ports:</strong></p>
                <pre class="+ topic/pre pr-d/codeblock pre codeblock"><code>
                    static inline void mcFoc_InputPortsRead( void  )
                    {
                    /** Please note that the ports may vary depending on your specific model. 
                    Please adjust as needed. */
                    #if ( X2CMODEL_TYPE == FLOATING_POINT_F32_MODEL )
                    x2cModel.inports.bI_a = (float32_t)mcCurI_ModuleData_gds.dOutput.iABC.a;
                    x2cModel.inports.bI_b = (float32_t)mcCurI_ModuleData_gds.dOutput.iABC.b;
                    x2cModel.inports.bV_POT = mcHalI_Potentiometer_gdu16 - 2048;
                    x2cModel.inports.bV_DCLINK = (float32_t)mcVolI_ModuleData_gds.dOutput.uBus;
                    #endif
                    
                    #if ( X2CMODEL_TYPE == FIXED_POINT_Q15_MODEL )
                    /** Scale phase currents
                    * Scaling:
                    *         Maximum measurable current -&gt; 32767 units,
                    *         Conversion Factor = 32767./ Maximum measurable current
                    *
                    *         For a MCLV-48V-300W board, maximum measurable current is 22 Amperes
                    *         Therefore, conversion factor ~ 1,489.409
                    */
                    x2cModel.inports.bI_a = -(int16_t)((float32_t)mcCurI_ModuleData_gds.dOutput.iABC.a * (float32_t)1489.409);
                    x2cModel.inports.bI_b = -(int16_t)((float32_t)mcCurI_ModuleData_gds.dOutput.iABC.b * (float32_t)1489.409);
                    
                    /**
                    Potentiometer scaling: [ 0 - 4095 ] -&gt; [ -32768, 32767 ]
                    */
                    x2cModel.inports.bV_POT = (int16_t)( mcHalI_Potentiometer_gdu16  - 2048 )&lt;&lt; 3U;
                   
                    /** Scale DC link voltage
                    * Scaling:
                    *         Maximum measurable voltage -&gt; 32767 units,
                    *         Conversion Factor = 32767/ Maximum measurable voltage
                    *
                    *         For a MCLV-48V-300W board, maximum measurable voltage is 72.9 Volts
                    *         Therefore, conversion factor ~ 449.478
                    */
                    x2cModel.inports.bV_DCLINK = (int16_t)((float32_t)mcVolI_ModuleData_gds.dOutput.uBus * (float32_t)449.478);
                    #endif
                    }
                </code></pre>
            </div>
            <div class="- topic/sectiondiv sectiondiv">
                <p class="- topic/p p"><strong class="+ topic/ph hi-d/b ph b">Output Ports:</strong></p>
                <pre class="+ topic/pre pr-d/codeblock pre codeblock"><code>
                    static inline void mcFoc_OutputPortsWrite( void  )
                    {
                    /** Please note that the ports may vary depending on your specific model. 
                    Please adjust as needed. */
                    #if ( X2CMODEL_TYPE == FLOATING_POINT_F32_MODEL )
                    float32_t dutyCycleFactor;
                    int16_t   periodCount;
                    int16_t   halfPeriodCount;
                    
                    /* Get the period count from mcHalI_PwmPeriodGet() */
                    periodCount = mcHalI_PwmPeriodGet();
                    
                    /* Calculate half of the period count */
                    halfPeriodCount = periodCount &gt;&gt; 1U;
                    
                    /* Calculate the duty cycle factor */
                    dutyCycleFactor = (float)periodCount / mcVolI_ModuleData_gds.dOutput.uBus;
                    
                    /* Update PWM duty cycles for three channels */
                    mcPwmI_Duty_gau16[0] = periodCount - (halfPeriodCount + *x2cModel.outports.bPWM1 * dutyCycleFactor);
                    mcPwmI_Duty_gau16[1] = periodCount - (halfPeriodCount + *x2cModel.outports.bPWM2 * dutyCycleFactor);
                    mcPwmI_Duty_gau16[2] = periodCount - (halfPeriodCount + *x2cModel.outports.bPWM3 * dutyCycleFactor);
                    #endif
                    
                    #if ( X2CMODEL_TYPE == FIXED_POINT_Q15_MODEL )
                    uint16_t duty[3U];
                    int16_t   periodCount;
                    
                    /* Get the period count from mcHalI_PwmPeriodGet() */
                    periodCount = mcHalI_PwmPeriodGet();
                    
                    
                    duty[0u] = (uint16_t)(((INT16_MAX - *x2cModel.outports.bPWM1) * periodCount)&gt;&gt;16);
                    duty[1u] = (uint16_t)(((INT16_MAX - *x2cModel.outports.bPWM2) * periodCount)&gt;&gt;16);
                    duty[2u] = (uint16_t)(((INT16_MAX - *x2cModel.outports.bPWM3) * periodCount)&gt;&gt;16);
                    
                    mcHalI_InverterPwmSet(duty);
                    #endif
                    }
                </code></pre>
            </div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-760A44FD-A4B3-42BA-AD96-578F04D8134D" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-760A44FD-A4B3-42BA-AD96-578F04D8134D"><h2 class="- topic/title title sectiontitle">10. Make and Program Device Project</h2>
            
            <p class="- topic/p p">Make and program the device project.</p>
            
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C07FCB34-A6A1-4C44-9979-CBCA1A540F37" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C07FCB34-A6A1-4C44-9979-CBCA1A540F37"><h2 class="- topic/title title sectiontitle">11. Verify X2C Communicator Communication</h2>
            
            <ol class="- topic/ol ol" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-AFC36208-E164-40BC-B355-AFD00A380946" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-AFC36208-E164-40BC-B355-AFD00A380946">
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-8CB0AA8F-ED58-465B-8D05-D505DE2EF24B" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-8CB0AA8F-ED58-465B-8D05-D505DE2EF24B">Click on "Start Communicator" (if not already open).</li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-08739993-F5B9-45B2-8CC9-6D4F7F14FAD1" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-08739993-F5B9-45B2-8CC9-6D4F7F14FAD1">Setup Serial Port.</li>
                <li class="- topic/li li" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-83439A82-63C8-4195-A66B-E08A31CC5AF6" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-83439A82-63C8-4195-A66B-E08A31CC5AF6">Click on "Connect to Target".</li>
            </ol>
            
            <div class="- topic/note note notype note_notype" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-4A6036D2-54C9-41FC-94AA-6F8593C641D1" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-4A6036D2-54C9-41FC-94AA-6F8593C641D1"><span class="note__title">Note:</span> 
                <p class="- topic/p p">Your model name and files may differ from those shown in the figure, depending on your configuration, model, and version.</p>
            </div>
        </section>
        
        <section class="- topic/section section" id="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-2BCDD2BA-2DB8-403D-8D8F-5D1E513774AF" data-ofbid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-2BCDD2BA-2DB8-403D-8D8F-5D1E513774AF"><h2 class="- topic/title title sectiontitle">12. Motor Operation, Variable Monitoring, and Tuning</h2>
            
            <p class="- topic/p p">Run the motor, monitor variables, and fine-tune your system parameters as needed for optimal performance.</p>
        </section>
    </div>
</article></main></div>
                        
                        
                        
                        
                        
                        
                    </div>
                    
                        <nav role="navigation" id="wh_topic_toc" aria-label="On this page" class="col-lg-2 d-none d-lg-block navbar d-print-none"> 
                            <div id="wh_topic_toc_content">
		                        
	                            <div class=" wh_topic_toc "><div class="wh_topic_label">On this page</div><ul><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-95205A12-24F9-4E17-85FB-6F9374F13B23" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-95205A12-24F9-4E17-85FB-6F9374F13B23">1. Install X2C Library</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-0C3637C8-4598-4C4C-AE27-E40E416EC54C" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-0C3637C8-4598-4C4C-AE27-E40E416EC54C">2. Configure Harmony QSpin GUI</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-057F0C76-F1F4-41C8-BA20-9516CDCFD6DF" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-057F0C76-F1F4-41C8-BA20-9516CDCFD6DF">3. Navigate to the Motor Control and Diagnosis Block</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-81A78B90-F177-4D2F-ABFE-BA985CEE166A" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-81A78B90-F177-4D2F-ABFE-BA985CEE166A">4. Enable Model-Based Development Option</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C03271F4-F804-44EC-B512-C05981E5A3B9" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C03271F4-F804-44EC-B512-C05981E5A3B9">5. Generate C Code from MCC</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-E130B9D4-8519-4A69-A468-707888102AA4" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-E130B9D4-8519-4A69-A468-707888102AA4">6. Launch Scilab for X2C-based Model-Based Design</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1B9CBDA1-5360-4FD5-980F-54598F67FBDA" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-1B9CBDA1-5360-4FD5-980F-54598F67FBDA">7. Model Creation in X2C</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-F2074090-283A-43A4-9BC4-EE2336D843FB" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-F2074090-283A-43A4-9BC4-EE2336D843FB">8. Transform and Generate Code</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-30B40A7B-8755-4878-B8EE-C28378EB60E1" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-30B40A7B-8755-4878-B8EE-C28378EB60E1">9. Update "readInports" and "writeOutports" Function Calls in MPLABX Project</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-760A44FD-A4B3-42BA-AD96-578F04D8134D" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-760A44FD-A4B3-42BA-AD96-578F04D8134D">10. Make and Program Device Project</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C07FCB34-A6A1-4C44-9979-CBCA1A540F37" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-C07FCB34-A6A1-4C44-9979-CBCA1A540F37">11. Verify X2C Communicator Communication</a></div></li><li class="section-item"><div class="section-title"><a href="#GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-2BCDD2BA-2DB8-403D-8D8F-5D1E513774AF" data-tocid="GUID-8E33A93C-1843-48AF-81A9-56CF2B306859__GUID-2BCDD2BA-2DB8-403D-8D8F-5D1E513774AF">12. Motor Operation, Variable Monitoring, and Tuning</a></div></li></ul></div>
	                        	
                        	</div>
                        </nav>
                    
                </div>
            </div>
            
            
            
        </div> 
        <footer class="navbar navbar-default wh_footer">
  <div class=" footer-container mx-auto ">
    <div class="footer">
  <div class="mchp-wh-footer">
    <div class="mchp-footer">
      <div class="mchp-footer-tier1">
        <div class="spacer"></div>
        <div class="mchp-footer-container">
          <div class="mchp-footer-links mchp-social-media-links">
            <div class="mchp-component-items">
              <div class="mchp-component-item">
                <a class="cmp-image__link" href="https://www.facebook.com/pages/Microchip-Technology-Inc/20320981741" target="_blank">
                  <img class="cmp-image__image" alt="Microchip Facebook" src="oxygen-webhelp/template/resources/images/201016-corp-facebook.png"/>
                </a>
              </div>
              <div class="mchp-component-item">
                <a class="cmp-image__link" href="https://www.linkedin.com/company/microchip-technology" target="_blank">
                  <img class="cmp-image__image" alt="Microchip LinkedIn" src="oxygen-webhelp/template/resources/images/201016-corp-linkedin.png"/>
                </a>
              </div>
              <div class="mchp-component-item">
                <a class="cmp-image__link" href="https://twitter.com/MicrochipTech" target="_blank">
                  <img class="cmp-image__image" alt="Microchip Twitter" src="oxygen-webhelp/template/resources/images/201016-corp-twitter.png"/>
                </a>
              </div>
              <div class="mchp-component-item">
                <a class="cmp-image__link" href="https://www.youtube.com/user/MicrochipTechnology" target="_blank">
                  <img class="cmp-image__image" alt="Microchip YouTube" src="oxygen-webhelp/template/resources/images/201016-corp-youtube.png"/>
                </a>
              </div>
              <div class="mchp-component-item">
                <a class="cmp-image__link" href="https://www.instagram.com/microchiptechnologyinc/" target="_blank">
                  <img class="cmp-image__image" alt="Microchip Instagram" src="oxygen-webhelp/template/resources/images/201016-corp-instagram.png"/>
                </a>
              </div>
              <div class="mchp-component-item">
                <a class="cmp-image__link" href="https://www.weibo.com/microchiptech" target="_blank">
                  <img class="cmp-image__image" alt="Microchip Weibo" src="oxygen-webhelp/template/resources/images/201016-corp-weibo.png"/>
                </a>
              </div>
              <div class="mchp-component-item">
                <a class="cmp-image__link" href="https://www.microchip.com/en-us/about/blog" target="_blank">
                  <img class="cmp-image__image" alt="Microchip Blog" src="oxygen-webhelp/template/resources/images/201016-corp-blog.png"/>
                </a>
              </div>
            </div>
          </div>
          <div class="mchp-footer-links">
            <div class="mchp-component-items">
              <div class="mchp-component-item">
                <div class="link">
                  <a href="https://www.microchip.com/about-us/contact-us" class="mchp-link__link">Contact</a>
                  <span class="mchp-link__separator">|</span>
                </div>
              </div>
              <div class="mchp-component-item ">
                <div class="link">
                  <a href="https://www.microchip.com/en-us/about/legal-information" class="mchp-link__link">Legal</a>
                  <span class="mchp-link__separator">|</span>
                </div>
              </div>
              <div class="mchp-component-item ">
                <div class="link">
                  <a href="https://www.microchip.com/en-us/about/legal-information/privacy-policy" class="mchp-link__link">Privacy Policy</a>
                  <span class="mchp-link__separator">|</span>
                </div>
              </div>
              <div class="mchp-component-item ">
                <div class="link">
                  <a href="https://www.microchip.com/en-us/about/legal-information/microchip-cookie-statement" class="mchp-link__link">Cookies</a>
                  <span class="mchp-link__separator">|</span>
                </div>
              </div>
              <div class="mchp-component-item">
                <div class="link">
                  <a href="https://careers.microchip.com/" class="mchp-link__link">Careers</a>
                  <span class="mchp-link__separator"></span>
                </div>
              </div>
            </div>
          </div>
          <div class="mchp-footer-newsletter">
            <div class="cmp-text">
              <p>Stay on the leading edge with our blog</p>
            </div>
            <div class="mchp-button-wrapper">
              <a role="button" href="https://www.microchip.com/en-us/about/blog" class="mchp-button mchp-button-regular solid">
                <span class="mchp-button__span">MicroSolutions</span>
              </a>
            </div>
          </div>
        </div>
        <div class="graphic">
          <img src="oxygen-webhelp/template/resources/images/footer-graphic.png"/>
        </div>
      </div>
      <div class="mchp-footer-tier2">
        <p class="mchp-copyright">© Copyright 1998-2022 Microchip Technology Inc. All rights reserved.</p>
      </div>
    </div>
  </div>
  <!-- Global site tag (gtag.js) - Google Analytics -->
  <script async="true" src="https://www.googletagmanager.com/gtag/js?id=UA-2724382-19"></script>
  <script>
    window.dataLayer = window.dataLayer || [];  
    function gtag(){dataLayer.push(arguments);}  
    gtag('js', new Date());   
    gtag('config', 'UA-2724382-19');
  </script>
  
  <script type="text/javascript">_satellite.pageBottom();</script><!-- Adobe Analytics -->
  <script type="text/javascript" src="mchp-js/prepend.js"></script><!-- Package for viewing PDFs on mobile devices -->
  
</div>
  </div>
</footer>
        
        <div id="go2top" class="d-print-none">
            <span class="oxy-icon oxy-icon-up"></span>
        </div>
        
        <div id="modal_img_large" class="modal">
            <span class="close oxy-icon oxy-icon-remove"></span>
            <div id="modal_img_container"></div>
            <div id="caption"></div>
        </div>
        
        
        
       
        </body>
</html>